$username)); $request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); $httpUtils ->expects($this->any()) ->method('checkRequestPath') ->will($this->returnValue(true)) ; $failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock(); $failureHandler ->expects($ok ? $this->never() : $this->once()) ->method('onAuthenticationFailure') ->will($this->returnValue(new Response())) ; $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager')->disableOriginalConstructor()->getMock(); $authenticationManager ->expects($ok ? $this->once() : $this->never()) ->method('authenticate') ->will($this->returnValue(new Response())) ; $listener = new UsernamePasswordFormAuthenticationListener( $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(), $authenticationManager, $this->getMockBuilder('Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock(), $httpUtils, 'TheProviderKey', $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface')->getMock(), $failureHandler, array('require_previous_session' => false) ); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') ->will($this->returnValue($request)) ; $listener->handle($event); } /** * @dataProvider postOnlyDataProvider * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException * @expectedExceptionMessage The key "_username" must be a string, "array" given. */ public function testHandleNonStringUsername($postOnly) { $request = Request::create('/login_check', 'POST', array('_username' => array())); $request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); $listener = new UsernamePasswordFormAuthenticationListener( new TokenStorage(), $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), new SessionAuthenticationStrategy(SessionAuthenticationStrategy::NONE), $httpUtils = new HttpUtils(), 'foo', new DefaultAuthenticationSuccessHandler($httpUtils), new DefaultAuthenticationFailureHandler($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $httpUtils), array('require_previous_session' => false, 'post_only' => $postOnly) ); $event = new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); $listener->handle($event); } public function postOnlyDataProvider() { return array( array(true), array(false), ); } public function getUsernameForLength() { return array( array(str_repeat('x', Security::MAX_USERNAME_LENGTH + 1), false), array(str_repeat('x', Security::MAX_USERNAME_LENGTH - 1), true), ); } } __halt_compiler();----SIGNATURE:----vTX6oJxw5P+d4D+ieU7w6VU6jf0wBxUWL900dBVkBqzMs9hwTroqkRKmV7Vy5XaIszrx+eB8ujMvDUMgxpWWVinmphikQPzf0OxjXLSeJY+WEjctLUQCGcmk4llprKVe/7Bqj85Hk7hIIryhYK/QleJVfttgAvr3nnluFO8PpZhf1gPUbPAjN5dvbDe4jxh79hiIdgaB3b0tL5Q4EcZX9NvqLdWf1ZsHXailOqTs/N4/kBEuMlsVoNdVVcmBi6bAYoLUkFTZDfHGPX6HQuFAzjbW5qlU20ow12gRuinrB5yVjwtrBLgg2H5BYBxuXIXTIESYqXZdsCkcjL2cyF7n0uFWi3mnqQsvMtSYJuSMmbAKNwa9wYzVa6mUoXIlFEjTleyFpJ0BrSiRdvzLHyywvTb38IwfmD5QSncC2cxY2jcwrMkY6zTH02pLZscvbOt1VmqjR1lgRWRGZxIDLWFw1T5STyeKjoc9xlze4DGa5OzjXYw2BXTQZWR7UT6+tnie7QMtZN0VjLFy/DUPP3nfZl3FpjSSkVo+trJI1m6yx17THYCQ3OI1nKlxLygJOu1JUOne+OJfpPSUWB0MnY89JavKxAT4eSSQEztSOC+WI5xPsIitV0jHnQHJ3vq9Az+n/s5bY55hBMQbpoRs5Fzso8lR6dq5y8Iqubm5lM9T8nA=----ATTACHMENT:----NDQ3MTgxODM1NTkxMTY1IDIxMDU1NjM5NjgzMzc2NjIgNDQ5NTk5MDMxMzkxODA3OQ==